package com.airforce.controller;

import com.airforce.mappers.user_awardMapper;
import com.airforce.utils.ResultCode;
import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping(value = "system")
@RestController
public class user_awardCon {


    @Autowired
    user_awardMapper user_awardMapper;

    private  final static Logger logger=LoggerFactory.getLogger(user_awardCon.class);

    //查看所有用户中奖列表
    @GetMapping("userawardlist")
    public Object userawardlist(    @RequestParam(required = false) String uuid,
                                    @RequestParam(required = false) int index ,
                                    @RequestParam(required = false) int num){

        List<Map<String,Object>> list ;
        int PageTotal=0;
        if(uuid==null||uuid==""){

            PageTotal=user_awardMapper.countmax();

            PageHelper.startPage(index,num);
            list=user_awardMapper.selectByuseraward_admin();
            return ResultCode.SUCCESS.result(list,PageTotal);
        }else {

            PageTotal=user_awardMapper.selectByuseraward_admin_uuid(uuid).size();
            PageHelper.startPage(index,num);
            list=user_awardMapper.selectByuseraward_admin_uuid(uuid);
            return ResultCode.SUCCESS.result(list,PageTotal);
        }


    }

    //删除用户中奖列表

    @GetMapping("userawardel")
    public Object userawardel(@RequestParam Integer id){
        logger.info("删除用户奖品");
        user_awardMapper.deleteByPrimaryKey(id);

        return ResultCode.SUCCESS.result();
    }






}
